/*
 * @lc app=leetcode.cn id=349 lang=cpp
 *
 * [349] 两个数组的交集
 */

// @lc code=start
class Solution
{
public:
    vector<int> intersection(vector<int> &nums1, vector<int> &nums2)
    {
        unordered_set<int> res;
        unordered_set<int> num1(nums1.begin(), nums1.end());
        for (int i = 0; i < nums2.size(); i++)
        {
            if (num1.find(nums2[i]) != num1.end())
            {
                res.emplace(nums2[i]);
            }
        }
        return vector<int>(res.begin(), res.end());
    }
};
// @lc code=end

